<script>
 $(document).ready(function ()
    {
        $('#data').dataTable( {
            "sPaginationType": "full_numbers",
            "bProcessing": true,
            "aaSorting": [[ 3, "desc" ],[ 1, "desc"]]
        });
    });
</script>
<fieldset>
	<div class="orders index">
		<h2><?php echo __('Orders'); ?></h2>
		<div class="newbutton">
			<ul>
				<li><?php echo $this->Html->link(__('Generate Orders'), array('action' => 'choosesupplier')); ?></li>
				<li><?php echo $this->Html->link(__('Edit PDF Trademark'), array('controller' => 'lukas','action' => 'edit','1')); ?></li>
			</ul>
		</div>
		<br/><br/>
		<table id="data" class="table" cellpadding="0" cellspacing="0">
		<thead>
		<tr>
				<th>Order Id</th>
				<th>Date Created</th>
				<th>Supplier Name</th>
				<th>Order Status</th>
				<th class="actions"><?php echo __('Actions'); ?></th>
		</tr>
		</thead>
		<tbody>
		<?php foreach ($orders as $order): ?>
		<tr>
			
			<td><?php echo h($order['Order']['id']); ?>&nbsp;</td>
			<td><?php echo h($order['Order']['created']); ?>&nbsp;</td>
			<td>
				<?php echo $this->Html->link($order['Suppliers']['supplierName'], array('controller' => 'suppliers', 'action' => 'view', $order['Suppliers']['id'])); ?>
			</td>
			<td><?php 	if($order['Order']['status'] == '0'){
							echo 'Not Completed';
						}
						else if($order['Order']['status'] == '2'){
							echo 'Partially Completed';
						}
						else{
							echo 'Completed';
						}
				?>&nbsp;</td>
			<td class="actions">
				<?php echo $this->Html->link(__('View'), array('action' => 'view', $order['Order']['id'])); ?>&nbsp;&nbsp;
				<?php echo $this->Form->postLink(__('Archive'), array('action' => 'delete', $order['Order']['id']), null, __('Are you sure you want to archive order number #%s?', $order['Order']['id'])); ?>&nbsp;&nbsp;
				<?php echo $this->Html->link(__('Generate PDF'), array('action' => 'viewPdf', $order['Order']['id'])); ?>&nbsp;&nbsp;
				<?php if($order['Order']['status'] != '1'){
						echo $this->Html->link(__('Receive Order'), array('controller' => 'deliveries','action' => 'delivery', $order['Order']['id']));} ?>		
			</td>
			
		</tr>
	<?php endforeach; ?>
	</tbody>
		</table>
	</div>
</fieldset>
